
class Solution {
public:
    string countAndSay(int n) {
        string s("1");
        int left, right;
        for (int i = 2;i <= n;i++)
        {
            string tmp;

            for (left = 0, right = 0;right < s.size();right++)
            {
                if (s[left] != s[right])
                {
                    tmp += to_string(right - left);
                    tmp += s[left];
                    left = right;
                }



            }
            tmp += to_string(right - left);
            tmp += s[left];
            s = tmp;




        }
        return s;


    }
};